package org.statewalker.dict;

public class Token implements IToken {

    private boolean fClose;

    private String fInternalKey;

    private String fKey;

    private boolean fOpen;

    public Token(String key) {
        this(key, true, false);
    }

    public Token(String key, boolean open, boolean close) {
        fKey = key;
        fInternalKey = key;
        fOpen = open;
        fClose = close;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (!(obj instanceof Token))
            return false;
        Token o = (Token) obj;
        return fKey.equals(o.fKey);
    }

    public String getInternalKey() {
        return fInternalKey;
    }

    /**
     * @see org.statewalker.dict.IToken#getKey()
     */
    public String getKey() {
        return fKey;
    }

    @Override
    public int hashCode() {
        return fKey.hashCode();
    }

    /**
     * @see org.statewalker.dict.IToken#isClose()
     */
    public boolean isClose() {
        return fClose;
    }

    /**
     * @see org.statewalker.dict.IToken#isOpen()
     */
    public boolean isOpen() {
        return fOpen;
    }

    public void setClose(boolean close) {
        fClose = close;
    }

    public void setInternalKey(String internalKey) {
        fInternalKey = internalKey;
    }

    /**
     * @see org.statewalker.dict.IToken#setKey(org.statewalker.dict.String)
     */
    public void setKey(String key) {
        fKey = key;
    }

    public void setOpen(boolean open) {
        fOpen = open;
    }

    @Override
    public String toString() {
        return getKey() + "";
    }

}
